﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;

namespace ChinaSoft.BLL.Common
{
    public class Bind
    {
        private readonly ChinaSoft.DAL.Common.Bind dal = new ChinaSoft.DAL.Common.Bind();
        /// <summary>
        /// 获取表明
        /// </summary>
        /// <param name="ColumnNames">列名（如查询所有，用*）</param>
        /// <param name="tablename">表名或者试图名</param>
        /// <param name="strwhere">查询条件</param>
        /// <returns></returns>
        public DataSet GetDataSet(string ColumnNames, string tablename, string strwhere)
        {
            return dal.GetDataSet(ColumnNames, tablename, strwhere);
        }
        public DataSet GetDataSet(string columnNames, string tableName, string strWhere, string orderby, string groupby)
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select "+columnNames+" from "+tableName+" ");
            return dal.GetDataSet(strsql.ToString());
        }
        /// <summary>
        /// 根据sql语句返回数据集
        /// </summary>
        /// <param name="sqlstr">sql语句</param>
        /// <returns></returns>
        public DataSet GetDataSet(string sqlstr)
        {
            return dal.GetDataSet(sqlstr);
        }
        /// <summary>
        /// 根据条件查询指定的字段的值
        /// 作者：demo
        /// 时间：2012-4-11
        /// </summary>
        /// <param name="Filed">字段名字</param>
        /// <param name="tableName">表名或者试图名字</param>
        /// <param name="sqlstr">条件（可空，条件需要全部自己写，如果需要where，则需要写where）</param>
        /// <returns></returns>
        public object GetFiledContent(string Filed, string tableName, string sqlstr)
        {
            return dal.GetFiledContent(Filed, tableName, sqlstr);
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string TableName, string KeyName, string CustomerIdlist)
        {
            return dal.DeleteList(TableName, KeyName, CustomerIdlist);
        }
        /// <summary>
        /// 根据条件删除指定信息
        /// 作者：demo
        /// 时间：2012-4-11
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="strWhere">条件（不带where）</param>
        /// <returns></returns>
        public bool DeleteWhere(string tableName, string strWhere)
        {
            return dal.DeleteWhere(tableName, strWhere);
        }
        /// <summary>
        /// 批量更新数据
        /// </summary>
        /// <param name="dataFileds">更新的字段</param>
        /// <param name="tableName">表名</param>
        /// <param name="strWhere">条件</param>
        /// <returns></returns>
        public bool UpdateList(string dataFileds, string tableName, string strWhere)
        {
            return dal.UpdateList(dataFileds, tableName, strWhere);
        }

    }
}
